import { Button } from 'antd';
import { useRef, useState } from 'react';
import { FormulaSetModel } from '../CommonFormulaSet';
import { RuleSetModal } from '../CommonRuleSet';
const RuleDemo: React.FC<any> = () => {
  /*
   *规则设置
   */
  const ruleSet = useRef<any>();
  const [id, setId] = useState<string>('1111');
  /**
   * 公式设置
   */
  const FormulaSet = useRef<any>();

  return (
    <div style={{ height: '100%', width: '100%', background: '#fff', padding: '16px' }}>
      <Button
        onClick={() => {
          ruleSet.current?.showModal();
        }}
      >
        规则设置弹窗Dmeo
      </Button>
      {/* 规则设置弹窗Dmeo */}
      <RuleSetModal
        innerRef={ruleSet}
        //type 1车辆相关，2司机相关，3驾驶行为
        type={1}
        //因子id
        id={id}
        onChange={() => {
          console.log('刷新列表等操作');
        }}
      />
      <Button
        onClick={() => {
          FormulaSet.current?.showModal({
            factorId: '11111', //因子id
            calculationRules: 2, //计算公式 2||3||4
          });
        }}
      >
        公式设置弹窗Dmeo
      </Button>
      {/* 公式设置弹窗Dmeo */}
      <FormulaSetModel
        innerRef={FormulaSet}
        relatedType={1} //relatedType 1车辆相关，2司机相关，3驾驶行为
        onChange={() => {
          console.log('刷新列表等操作');
        }}
      />
    </div>
  );
};

export default RuleDemo;
